NoSQL operator: formtable
Print an arbitrary style report of a NoSQL table.
Usage: formtable [options] file.frm
Options:
--help (-h)
Display this help text.
--page-size=N (-pN)
Page size is N lines. Default is 60 lines.
--debug (-x)
Debug option.
Notes:
Formats and prints an arbitrary style report, as specified in the file
"file.frm". An (optional) page header may be specified.
The format of a form file is similar to a PERL format, except that
column names are used (without separating commas) instead of variable
names. The form file contains regular text, picture fields and
associated column names. Regular text prints just as given. Picture
fields define the width and justification for printing a data value from
a column. The names of the associated columns are listed on the line
following the picture fields and in the same order. Note that this file
should not contain any TAB characters; space characters should be used
instead.
Picture fields start with either '@' or '^' and are followed by one
of three primary characters to define the width of the field. The
three characters are '<', '>', or '|' to specify left, right, or
center justification respectively. There is also an alternate right
justification character for printing numeric data, with optional decimal
point. The character is the sharp sign '#' and a period specifies the
decimal point placement, as in '@########.##'.
A numeric picture field has the following features:
- Data is lined up on the decimal point (if any).
- Automatic rounding of data.
- Automatic conversion of data in scientific notation.
Numeric Data may be in the form of integers, fixed point, or scientific
notation' e.g. 12345, 4567.345, or 1.678E17.
Normally picture fields start with the '@' character. That means to put
the referenced data value into the defined picture field, or as much
of the data as will fit into the field, if the data is larger than the
field. If the field starts with the '^' character it means to repeat the
field on as many lines as necessary in order to print the entire data
value. This is useful for large data fields, such as comments or free
text.
Instead of a column name there are some special names that can be used
to have other information inserted. This are especially useful if there
is a page header:
Special Name Substituted in output
------------ -----------------------------------------------
_pgnr_ current page number
_date_ current date
_rcnr_ current record number (row number)
_`cmd`_ the output of the command 'cmd'
As an example, let's take the following sample table:
NAME COUNT TYP AMT OTHER RIGHT
------ ----- ---- ----- -------- --------
Bush 44 A 133 Another This
Hansen 44 A 23 One Is
Jones 77 X 77 Here On
Perry 77 B 244 And The
Hart 77 D 1111 So Right
Holmes 65 D 1111 On Edge
Here is an example of a form file for use with such table:
----------------------------- cut -----------------------------------
format top =
Page @>, The Page Header @<<<<<<<<<<<<<<<<<<<<<<<<<<<
_pgnr_ _date_
.
format =
Name: @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Type: @>>>>
NAME TYP
Total: @<<<<<<<< Other: @<<<<<<<<<<<<<<<
AMT OTHER
.
----------------------------- cut -----------------------------------
The first and last lines (those that start with 'format' or a single
period) define the pictorial records and must be as shown. The first
record defines the header and is optional. If such form file (named
sample.frm) were used in the command:
formtable sample.frm < table
it would produce the following one-page report:
----------------------------- cut -----------------------------------
Page 1, The Page Header Mon Dec 2 16:21:18 PST 1991
Name: Bush Type: A
Total: 133 Other: Another
Name: Hansen Type: A
Total: 23 Other: One
Name: Jones Type: X
Total: 77 Other: Here
Name: Perry Type: B
Total: 244 Other: And
Name: Hart Type: D
Total: 1111 Other: So
Name: Holmes Type: D
Total: 1111 Other: On
----------------------------- cut -----------------------------------
For another example, one might want to have a date on a report in other
than the standard date output format, and an idea of who executed the
program, and have a reference count of the records being produced. The
form file might be as follows:
----------------------------- cut -----------------------------------
format top =
Run By: @<<<<<<< The Date/Time is @<<<<<<<<<<<<<<<<<<<<<<<<
_`whoami`_ _`date "+%m/%d/%y %H:%M"`_
.
format =
RecordNr: @>> @<<<<<<<<<<<<<<<<<<<<
_rcnr_ OTHER
.
----------------------------- cut -----------------------------------
When used against the above sample table, such form file would produce:
----------------------------- cut -----------------------------------
Run By: hobbs The Date/Time is 10/15/91 09:43
RecordNr: 1 Other data here
RecordNr: 2 and here,
RecordNr: 3 and so on.
... ... ...
----------------------------- cut -----------------------------------
Another example shows how longer data values can be
handled. Let's take this other form file:
----------------------------- cut -----------------------------------
format top =
Page @>, Page Header here @<<<<<<<<<<<<<
_pgnr_ _`date "+%m/%d/%y %H:%M"`_
Executed by @<<<<<<< on: @<<<<<<<<<
`whoami` _`hostname`_
format =
Name: @<<<<<<<<<<<<<<< Other: @<<<<<<<<<< Type: @<<<<<<<<
NAME OTHER TYP
Comment: ^<<<<<<<<<<<<<< Long: ^<<<<<<<<<<<<<< Right: @>>>>>>>
COMMENT LONG RIGHT
=======================================================================
----------------------------- cut -----------------------------------
When used against the above sample table, such form would produce:
----------------------------- cut -----------------------------------
Page 1, Page Header here 12/02/91 16:32
Executed by hobbs on: id
Name: Bush Other: Another Type: A
Comment: A comment Long: This a long Right: This
here. message for
test.
=======================================================================
Name: Hansen Other: One Type: A
Comment: A longer Long: This a long Right: Is
comment here. message for
test.
=======================================================================
Name: Jones Other: Here Type: X
Comment: A longer, Long: Short test. Right: On
longer comment
here.
=======================================================================
Name: Perry Other: And Type: B
Comment: A short comment Long: This a long Right: The
here. message for
test.
=======================================================================
Name: Hart Other: So Type: D
Comment: Little here. Long: Here too. Right: Right
=======================================================================
Name: Holmes Other: On Type: D
Comment: A comment here Long: A short Right: Edge
that is a message.
little ongoing,
so to speak.
=======================================================================
----------------------------- cut -----------------------------------
Note that since there were two picture fields that started with the '^'
character on one line the length of output records varies according to
the length of the two associated data values.